//declare global {
interface Array<T> {
    Add(t: T): void;
    Remove(t: T): boolean;
    Contains(t: T): boolean;
    RemoveAt(index: number): void;
    Min(predict: (t: T) => void): T;
    Max(predict: (t: T) => void): T;
}
//}
Array.prototype.Add = function (item) {
    this.push(item);
}
Array.prototype.Remove = function (item) {
    var i = this.indexOf(item);
    if (i >= 0) {
        this.splice(i, 1);
        return true;
    }
    else {
        return false;
    }
}
Array.prototype.Contains = function (item) {
    return this.indexOf(item) >= 0;
}
Array.prototype.RemoveAt = function (index) {
    if (this[index]) {
        this.splice(index, 1);
        return true;
    }
    else {
        return false;
    }
}
Array.prototype.Min = function (predict) {
    let min = this[0];
    let minValue = predict(min);
    for (const v of this) {
        let tempValue = predict(v);
        if (tempValue < minValue) {
            min = v;
            minValue = tempValue;
        }
    }
    return min;
}
Array.prototype.Max = function (predict) {
    let max = this[0];
    let maxValue = predict(max);
    for (const v of this) {
        let tempValue = predict(v);
        if (tempValue > maxValue) {
            max = v;
            maxValue = tempValue;
        }
    }
    return max;
}